//
//  ViewController.m
//  马蜂午分享
//
//  Created by dllo on 16/8/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>

@interface ViewController ()<MKMapViewDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *mapView;




@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _mapView.delegate = self;
    MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
    annotation.coordinate = CLLocationCoordinate2DMake(31.2, 121.4);
    [_mapView addAnnotation:annotation];
    annotation.title = @"上海";
    annotation.subtitle = @"在这儿";
    

}

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
    
}
- (IBAction)shanghaiAction:(id)sender {
    _mapView.region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(31.2, 121.4), MKCoordinateSpanMake(1, 1));
    
    
    
}

- (IBAction)dingweiAction:(id)sender {
    
    CLLocation *location = _mapView.userLocation.location;
    _mapView.region = MKCoordinateRegionMake(location.coordinate, MKCoordinateSpanMake(1, 1));
    
    
    
    
}


- (nullable MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    MKAnnotationView *view = [[MKAnnotationView alloc] init];
    view.image = [UIImage imageNamed:@"123"];
    view.canShowCallout = YES;
    return view;
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
